import { createRouter, createWebHashHistory } from "vue-router";
import MainLayout from "@/views/layouts/MainLayout.vue";

const routes = [
  {
    path: "/",
    redirect: { name: "login" },
  },
  {
    path: "/login",
    name: "login",
    component: () =>
      import(/* webpackChunkName: "auth" */ "../views/auth/LoginView.vue"),
  },
  {
    path: "/forgotpassword",
    name: "forgotpassword",
    component: () =>
      import(
        /* webpackChunkName: "auth" */ "../views/auth/ForgotPasswordView.vue"
      ),
  },
  {
    path: "/page",
    component: MainLayout, // 嵌套在主布局中
    children: [
      {
        path: "",
        redirect: { name: "home" },
      },
      {
        // 子路由路径不要带 '/' 前缀，会自动继承父路径
        path: "home",
        name: "home",
        component: () =>
          import(/* webpackChunkName: "home" */ "../views/home/HomeView.vue"),
      },
      {
        path: "monitoring",
        name: "monitoring",
        component: () =>
          import(
            /* webpackChunkName: "monitoring" */ "../views/monitoring/MonitoringView.vue"
          ),
      },
      {
        path: "announcement",
        name: "announcement",
        component: () =>
          import(
            /* webpackChunkName: "announcement" */ "../views/announcement/AnnouncementView.vue"
          ),
      },
      {
        path: "basic/airport",
        name: "airport",
        component: () =>
          import(
            /* webpackChunkName: "basic" */ "../views/basic/AirportView.vue"
          ),
      },
      {
        path: "basic/area",
        name: "area",
        component: () =>
          import(/* webpackChunkName: "basic" */ "../views/basic/AreaView.vue"),
      },
      {
        path: "basic/route",
        name: "route",
        component: () =>
          import(
            /* webpackChunkName: "basic" */ "../views/basic/RouteView.vue"
          ),
      },
      {
        path: "basic/ephemeris",
        name: "ephemeris",
        component: () =>
          import(
            /* webpackChunkName: "basic" */ "../views/basic/EphemerisView.vue"
          ),
      },
      {
        path: "basic/nanu",
        name: "nanu",
        component: () =>
          import(/* webpackChunkName: "basic" */ "../views/basic/nanuView.vue"),
      },
      {
        path: "basic/notam",
        name: "notam",
        component: () =>
          import(
            /* webpackChunkName: "basic" */ "../views/basic/notamView.vue"
          ),
      },
      {
        path: "basic/demo",
        name: "demo",
        component: () =>
          import(/* webpackChunkName: "basic" */ "../views/basic/DemoView.vue"),
      },
      {
        path: "log/user",
        name: "user",
        component: () =>
          import(/* webpackChunkName: "log" */ "../views/log/UserView.vue"),
      },
      {
        path: "log/operation",
        name: "operation",
        component: () =>
          import(
            /* webpackChunkName: "log" */ "../views/log/OperationView.vue"
          ),
      },
      {
        path: "log/system",
        name: "system",
        component: () =>
          import(/* webpackChunkName: "log" */ "../views/log/SystemView.vue"),
      },
      {
        path: "user/approval",
        name: "approval",
        component: () =>
          import(
            /* webpackChunkName: "user" */ "../views/user/ApprovalView.vue"
          ),
      },
      {
        path: "user/manage",
        name: "manage",
        component: () =>
          import(/* webpackChunkName: "user" */ "../views/user/ManageView.vue"),
      },
      {
        path: "user/role",
        name: "role",
        component: () =>
          import(/* webpackChunkName: "user" */ "../views/user/RoleView.vue"),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
